import React from 'react';
import {
    useNavigate
} from "react-router-dom";
const userList = ["zhangsan","lisi","wangwu","zhao"]
function Login(props) {
    const navigate = useNavigate();
    return (
        <div>
            <input onKeyUp={e=>{
                if(e.keyCode === 13){
                    if(userList.includes(e.target.value.trim())){
                        localStorage.setItem("userName",e.target.value.trim());
                        navigate("/my");

                    }else{
                        alert("您输入的账号不正确");
                        e.target.value = null;
                    }
                }
            }} type="text" placeholder={"请输入用户名按回车登陆"}/>
        </div>
    );
}

export default Login;